home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / examples / FileSB.lsp < prev    next >
Encoding:
Lisp/Scheme  |  1991-10-05  |  11.6 KB  |  370 lines

  1. ; -*-Lisp-*-
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; File:         FileSB.lsp
  5. ; RCS:          $Header: FileSB.lsp,v 1.2 91/10/05 02:32:53 mayer Exp $
  6. ; Description:  Demo of XM_FILE_SELECTION_BOX_WIDGET_CLASS
  7. ; Author:       Niels Mayer, HPLabs
  8. ; Created:      Sun Feb 10 20:32:40 1991
  9. ; Modified:     Sat Oct  5 02:30:51 1991 (Niels Mayer) mayer@hplnpm
  10. ; Language:     Lisp
  11. ; Package:      N/A
  12. ; Status:       X11r5 contrib tape release
  13. ;
  14. ; WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. ; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. ;
  17. ; Permission to use, copy, modify, distribute, and sell this software and its
  18. ; documentation for any purpose is hereby granted without fee, provided that
  19. ; the above copyright notice appear in all copies and that both that
  20. ; copyright notice and this permission notice appear in supporting
  21. ; documentation, and that the name of Hewlett-Packard and Niels Mayer not be
  22. ; used in advertising or publicity pertaining to distribution of the software
  23. ; without specific, written prior permission.  Hewlett-Packard and Niels Mayer
  24. ; makes no representations about the suitability of this software for any
  25. ; purpose.  It is provided "as is" without express or implied warranty.
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27.  
  28. (let ()
  29.  
  30. (setq top_w
  31.       (send TOP_LEVEL_SHELL_WIDGET_CLASS :new "fsb"
  32.         :XMN_TITLE "FileSB Widget Test"
  33.         :XMN_ICON_NAME "Test"
  34.         ))
  35.  
  36. (setq fsb_w 
  37.       (send XM_FILE_SELECTION_BOX_WIDGET_CLASS :new :managed
  38.         "files" top_w
  39.     ))
  40.  
  41. (setq cb1 (send fsb_w :set_callback :XMN_APPLY_CALLBACK
  42.         (if (and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  43.             '(            ;for Motif 1.1
  44.               CALLBACK_WIDGET
  45.               CALLBACK_REASON
  46.               CALLBACK_XEVENT
  47.               CALLBACK_VALUE
  48.               CALLBACK_LENGTH
  49.               CALLBACK_MASK
  50.               CALLBACK_MASK_LENGTH
  51.               CALLBACK_DIR
  52.               CALLBACK_DIR_LENGTH
  53.               CALLBACK_PATTERN
  54.               CALLBACK_PATTERN_LENGTH
  55.               )
  56.           '(            ;for Motif 1.0
  57.             CALLBACK_WIDGET
  58.             CALLBACK_REASON
  59.             CALLBACK_XEVENT
  60.             CALLBACK_VALUE
  61.             CALLBACK_LENGTH
  62.             CALLBACK_MASK
  63.             CALLBACK_MASK_LENGTH
  64.             )
  65.           )
  66.         '(
  67.           (format T "-------------------------------------------\n")
  68.           (format T "widget=~A, reason=~A, xevent=~A\n" 
  69.               callback_widget callback_reason callback_xevent)
  70.           (format T "CALLBACK_VALUE=~A\n"
  71.               (xm_string_get_l_to_r CALLBACK_VALUE))
  72.           (format T "CALLBACK_LENGTH=~A\n"
  73.               CALLBACK_LENGTH)
  74.           (format T "CALLBACK_MASK=~A\n"
  75.               (xm_string_get_l_to_r CALLBACK_MASK))
  76.           (format T "CALLBACK_MASK_LENGTH=~A\n"
  77.               CALLBACK_MASK_LENGTH)
  78.           (cond ((and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  79.              (format T "CALLBACK_DIR=~A\n"
  80.                  (xm_string_get_l_to_r CALLBACK_DIR))
  81.              (format T "CALLBACK_DIR_LENGTH=~A\n"
  82.                  CALLBACK_DIR_LENGTH)
  83.              (format T "CALLBACK_PATTERN=~A\n"
  84.                  (xm_string_get_l_to_r CALLBACK_PATTERN))
  85.              (format T "CALLBACK_PATTERN_LENGTH=~A\n"
  86.                  CALLBACK_PATTERN_LENGTH)
  87.              (let* ((items_array (send fsb_w :GET_DIR_LIST_ITEMS))
  88.                 (items_length (length items_array))
  89.                 )
  90.                (format T "Dir-List Items:\n")
  91.                (do ((i 0 (1+ i)))
  92.                    ((= i items_length))
  93.                    (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  94.                )
  95.              (let* ((items_array  (send fsb_w :GET_FILE_LIST_ITEMS))
  96.                 (items_length (length items_array))
  97.                 )
  98.                (format T "File-List Items:\n")
  99.                (do ((i 0 (1+ i)))
  100.                    ((= i items_length))
  101.                    (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  102.                )
  103.              ))
  104.           )
  105.         ))
  106.  
  107. (setq cb2 (send fsb_w :set_callback :XMN_OK_CALLBACK
  108.         (if (and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  109.             '(            ;for Motif 1.1
  110.               CALLBACK_WIDGET
  111.               CALLBACK_REASON
  112.               CALLBACK_XEVENT
  113.               CALLBACK_VALUE
  114.               CALLBACK_LENGTH
  115.               CALLBACK_MASK
  116.               CALLBACK_MASK_LENGTH
  117.               CALLBACK_DIR
  118.               CALLBACK_DIR_LENGTH
  119.               CALLBACK_PATTERN
  120.               CALLBACK_PATTERN_LENGTH
  121.               )
  122.           '(            ;for Motif 1.0
  123.             CALLBACK_WIDGET
  124.             CALLBACK_REASON
  125.             CALLBACK_XEVENT
  126.             CALLBACK_VALUE
  127.             CALLBACK_LENGTH
  128.             CALLBACK_MASK
  129.             CALLBACK_MASK_LENGTH
  130.             )
  131.           )
  132.         '(
  133.           (format T "-------------------------------------------\n")
  134.           (format T "widget=~A, reason=~A, xevent=~A\n" 
  135.               callback_widget callback_reason callback_xevent)
  136.           (format T "CALLBACK_VALUE=~A\n"
  137.               (xm_string_get_l_to_r CALLBACK_VALUE))
  138.           (format T "CALLBACK_LENGTH=~A\n"
  139.               CALLBACK_LENGTH)
  140.           (format T "CALLBACK_MASK=~A\n"
  141.               (xm_string_get_l_to_r CALLBACK_MASK))
  142.           (format T "CALLBACK_MASK_LENGTH=~A\n"
  143.               CALLBACK_MASK_LENGTH)
  144.           (cond ((and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  145.              (format T "CALLBACK_DIR=~A\n"
  146.                  (xm_string_get_l_to_r CALLBACK_DIR))
  147.              (format T "CALLBACK_DIR_LENGTH=~A\n"
  148.                  CALLBACK_DIR_LENGTH)
  149.              (format T "CALLBACK_PATTERN=~A\n"
  150.                  (xm_string_get_l_to_r CALLBACK_PATTERN))
  151.              (format T "CALLBACK_PATTERN_LENGTH=~A\n"
  152.                  CALLBACK_PATTERN_LENGTH)
  153.              (let* ((items_array (send fsb_w :GET_DIR_LIST_ITEMS))
  154.                 (items_length (length items_array))
  155.                 )
  156.                (format T "Dir-List Items:\n")
  157.                (do ((i 0 (1+ i)))
  158.                    ((= i items_length))
  159.                    (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  160.                )
  161.              (let* ((items_array  (send fsb_w :GET_FILE_LIST_ITEMS))
  162.                 (items_length (length items_array))
  163.                 )
  164.                (format T "File-List Items:\n")
  165.                (do ((i 0 (1+ i)))
  166.                    ((= i items_length))
  167.                    (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  168.                )
  169.              ))
  170.           )
  171.         ))
  172.  
  173. (setq cb3 (send fsb_w :set_callback :XMN_CANCEL_CALLBACK
  174.         (if (and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  175.             '(            ;for Motif 1.1
  176.               CALLBACK_WIDGET
  177.               CALLBACK_REASON
  178.               CALLBACK_XEVENT
  179.               CALLBACK_VALUE
  180.               CALLBACK_LENGTH
  181.               CALLBACK_MASK
  182.               CALLBACK_MASK_LENGTH
  183.               CALLBACK_DIR
  184.               CALLBACK_DIR_LENGTH
  185.               CALLBACK_PATTERN
  186.               CALLBACK_PATTERN_LENGTH
  187.               )
  188.           '(            ;for Motif 1.0
  189.             CALLBACK_WIDGET
  190.             CALLBACK_REASON
  191.             CALLBACK_XEVENT
  192.             CALLBACK_VALUE
  193.             CALLBACK_LENGTH
  194.             CALLBACK_MASK
  195.             CALLBACK_MASK_LENGTH
  196.             )
  197.           )
  198.         '(
  199.           (format T "-------------------------------------------\n")
  200.           (format T "widget=~A, reason=~A, xevent=~A\n" 
  201.               callback_widget callback_reason callback_xevent)
  202.           (format T "CALLBACK_VALUE=~A\n"
  203.               (xm_string_get_l_to_r CALLBACK_VALUE))
  204.           (format T "CALLBACK_LENGTH=~A\n"
  205.               CALLBACK_LENGTH)
  206.           (format T "CALLBACK_MASK=~A\n"
  207.               (xm_string_get_l_to_r CALLBACK_MASK))
  208.           (format T "CALLBACK_MASK_LENGTH=~A\n"
  209.               CALLBACK_MASK_LENGTH)
  210.           (cond ((and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  211.              (format T "CALLBACK_DIR=~A\n"
  212.                  (xm_string_get_l_to_r CALLBACK_DIR))
  213.              (format T "CALLBACK_DIR_LENGTH=~A\n"
  214.                  CALLBACK_DIR_LENGTH)
  215.              (format T "CALLBACK_PATTERN=~A\n"
  216.                  (xm_string_get_l_to_r CALLBACK_PATTERN))
  217.              (format T "CALLBACK_PATTERN_LENGTH=~A\n"
  218.                  CALLBACK_PATTERN_LENGTH)
  219.              (let* ((items_array (send fsb_w :GET_DIR_LIST_ITEMS))
  220.                 (items_length (length items_array))
  221.                 )
  222.                (format T "Dir-List Items:\n")
  223.                (do ((i 0 (1+ i)))
  224.                    ((= i items_length))
  225.                    (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  226.                )
  227.              (let* ((items_array  (send fsb_w :GET_FILE_LIST_ITEMS))
  228.                 (items_length (length items_array))
  229.                 )
  230.                (format T "File-List Items:\n")
  231.                (do ((i 0 (1+ i)))
  232.                    ((= i items_length))
  233.                    (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  234.                )
  235.              ))
  236.           )
  237.         ))
  238.  
  239. (setq cb4 (send fsb_w :set_callback :XMN_NO_MATCH_CALLBACK
  240.         (if (and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  241.             '(            ;for Motif 1.1
  242.               CALLBACK_WIDGET
  243.               CALLBACK_REASON
  244.               CALLBACK_XEVENT
  245.               CALLBACK_VALUE
  246.               CALLBACK_LENGTH
  247.               CALLBACK_MASK
  248.               CALLBACK_MASK_LENGTH
  249.               CALLBACK_DIR
  250.               CALLBACK_DIR_LENGTH
  251.               CALLBACK_PATTERN
  252.               CALLBACK_PATTERN_LENGTH
  253.               )
  254.           '(            ;for Motif 1.0
  255.             CALLBACK_WIDGET
  256.             CALLBACK_REASON
  257.             CALLBACK_XEVENT
  258.             CALLBACK_VALUE
  259.             CALLBACK_LENGTH
  260.             CALLBACK_MASK
  261.             CALLBACK_MASK_LENGTH
  262.             CALLBACK_DIR
  263.             CALLBACK_DIR_LENGTH
  264.             CALLBACK_PATTERN
  265.             CALLBACK_PATTERN_LENGTH
  266.             )
  267.           )
  268.         '(
  269.           (format T "-------------------------------------------\n")
  270.           (format T "widget=~A, reason=~A, xevent=~A\n" 
  271.               callback_widget callback_reason callback_xevent)
  272.           (format T "CALLBACK_VALUE=~A\n"
  273.               (xm_string_get_l_to_r CALLBACK_VALUE))
  274.           (format T "CALLBACK_LENGTH=~A\n"
  275.               CALLBACK_LENGTH)
  276.           (format T "CALLBACK_MASK=~A\n"
  277.               (xm_string_get_l_to_r CALLBACK_MASK))
  278.           (format T "CALLBACK_MASK_LENGTH=~A\n"
  279.               CALLBACK_MASK_LENGTH)
  280.           (cond ((and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  281.              (format T "CALLBACK_DIR=~A\n"
  282.                  (xm_string_get_l_to_r CALLBACK_DIR))
  283.              (format T "CALLBACK_DIR_LENGTH=~A\n"
  284.                  CALLBACK_DIR_LENGTH)
  285.              (format T "CALLBACK_PATTERN=~A\n"
  286.                  (xm_string_get_l_to_r CALLBACK_PATTERN))
  287.              (format T "CALLBACK_PATTERN_LENGTH=~A\n"
  288.                  CALLBACK_PATTERN_LENGTH)
  289.              (let* ((items_array (send fsb_w :GET_DIR_LIST_ITEMS))
  290.                 (items_length (length items_array))
  291.                 )
  292.                (format T "Dir-List Items:\n")
  293.                (do ((i 0 (1+ i)))
  294.                    ((= i items_length))
  295.                    (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  296.                )
  297.              (let* ((items_array  (send fsb_w :GET_FILE_LIST_ITEMS))
  298.                 (items_length (length items_array))
  299.                 )
  300.                (format T "File-List Items:\n")
  301.                (do ((i 0 (1+ i)))
  302.                    ((= i items_length))
  303.                    (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  304.                )
  305.              ))
  306.  
  307.           )
  308.         ))
  309.  
  310. (send top_w :realize)
  311.  
  312. (if (and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  313.     (let* ((items_array (send fsb_w :GET_DIR_LIST_ITEMS))
  314.        (items_length (length items_array))
  315.        )
  316.       (do ((i 0 (1+ i)))
  317.       ((= i items_length))
  318.       (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  319.       )
  320.   )
  321.  
  322. (if (and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  323.     (let* ((items_array  (send fsb_w :GET_FILE_LIST_ITEMS))
  324.        (items_length (length items_array))
  325.        )
  326.       (do ((i 0 (1+ i)))
  327.       ((= i items_length))
  328.       (format T "\t~A\n" (xm_string_get_l_to_r (aref items_array i))))
  329.       )
  330.   )
  331.  
  332. )
  333.  
  334.  
  335. (send fsb_w :do_search "/tmp/*")
  336.  
  337. (format T ":DIALOG_FILTER_LABEL==~A\n"
  338.     (send fsb_w :get_child :DIALOG_FILTER_LABEL))
  339. (format T ":DIALOG_FILTER_TEXT==~A\n"
  340.     (send fsb_w :get_child :DIALOG_FILTER_TEXT))
  341. (if (and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  342.     (format T ":DIALOG_DIR_LIST==~A\n"
  343.         (send fsb_w :get_child :DIALOG_DIR_LIST)))
  344. (if (and (eq *MOTIF_VERSION* 1) (eq *MOTIF_REVISION* 1))
  345.     (format T ":DIALOG_DIR_LIST_LABEL==~A\n"
  346.         (send fsb_w :get_child :DIALOG_DIR_LIST_LABEL)))
  347. (format T ":DIALOG_LIST==~A\n"
  348.     (send fsb_w :get_child :DIALOG_LIST))
  349. (format T ":DIALOG_LIST_LABEL==~A\n"
  350.     (send fsb_w :get_child :DIALOG_LIST_LABEL))
  351. (format T ":DIALOG_SELECTION_LABEL==~A\n"
  352.     (send fsb_w :get_child :DIALOG_SELECTION_LABEL))
  353. (format T ":DIALOG_WORK_AREA==~A\n"
  354.     (send fsb_w :get_child :DIALOG_WORK_AREA))
  355. (format T ":DIALOG_TEXT==~A\n"
  356.     (send fsb_w :get_child :DIALOG_TEXT))
  357. (format T ":DIALOG_SEPARATOR==~A\n"
  358.     (send fsb_w :get_child :DIALOG_SEPARATOR))
  359. (format T ":DIALOG_OK_BUTTON==~A\n"
  360.     (send fsb_w :get_child :DIALOG_OK_BUTTON))
  361. (format T ":DIALOG_APPLY_BUTTON==~A\n"
  362.     (send fsb_w :get_child :DIALOG_APPLY_BUTTON))
  363. (format T ":DIALOG_CANCEL_BUTTON==~A\n"
  364.     (send fsb_w :get_child :DIALOG_CANCEL_BUTTON))
  365. (format T ":DIALOG_HELP_BUTTON==~A\n"
  366.     (send fsb_w :get_child :DIALOG_HELP_BUTTON))
  367. (format T ":DIALOG_DEFAULT_BUTTON==~A\n"
  368.     (send fsb_w :get_child :DIALOG_DEFAULT_BUTTON))
  369.  
  370.